package com.demo.io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class FileWriteTest {
    public static void main(String[] args) throws IOException {
        // 1.创建输出流
        FileOutputStream fs = new FileOutputStream("db.txt");
        // 2.写数据到流
        fs.write("hello world".getBytes(StandardCharsets.UTF_8));

        // 3. 关闭流
        fs.flush(); //刷新缓冲区的内容
        fs.close();
    }
}
